package com.usian.controller;

import com.usian.feign.ContestFeign;
import com.usian.feign.CourseFeign;
import com.usian.feign.LabelFeign;
import com.usian.feign.TrainFeign;
import com.usian.pojo.B.day09.Course;
import com.usian.r.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @author BYBL
 * @date 2023/8/23
 */
@RestController
public class CourseController {
    @Autowired
    CourseFeign courseFeign;

    @Autowired
    ContestFeign contestFeign;

    @Autowired
    TrainFeign trainFeign;
    @Autowired
    LabelFeign labelFeign;

    @Autowired
    RedisTemplate redisTemplate;

    @RequestMapping("course/findUid")
    public R findUid(Integer mid){
        try {
            R uid1 = courseFeign.findUid(mid);
            return R.success(uid1);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

    @RequestMapping("/contest/findUid")
    public R findUid1(Integer memberId){
        try {
            R uid1 = contestFeign.findUid1(memberId);
            return R.success(uid1);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

    @RequestMapping("/train/findUid")
    public R findUid2(Integer memberId){
        try {
            R uid1 = trainFeign.findUid2(memberId);
            return R.success(uid1);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

    @GetMapping("/course/findHot")
    public R findHot(Course course){
        try {
            R hot = courseFeign.findHot(course);
            return R.success(hot);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

    //标签调用
    @RequestMapping("/label/list")
    public R list(){
        try {
            R list = labelFeign.list();
            return list;
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }
}